package com.test.android.flavor.android;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

/**
 * 简化版主页Activity
 */
public class MainActivity extends AppCompatActivity {
    
    private Button btnGoToHome;
    private Button btnGoToShop;
    private Button btnGoToOrder;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_hierarchy);
        
        initViews();
        setListeners();
    }
    
    private void initViews() {
        btnGoToHome = findViewById(R.id.btn_go_to_home);
        btnGoToShop = findViewById(R.id.btn_go_to_shop);
        btnGoToOrder = findViewById(R.id.btn_go_to_order);
    }
    
    private void setListeners() {
        btnGoToHome.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 跳转到home模块的首页
                try {
                    Intent intent = new Intent();
                    intent.setClassName(MainActivity.this, "com.test.android.flavor.android.home.HomeActivity");
                    startActivity(intent);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        
        btnGoToShop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 跳转到shop模块的页面
                try {
                    Intent intent = new Intent();
                    intent.setClassName(MainActivity.this, "com.test.android.flavor.android.shop.ShopActivity");
                    startActivity(intent);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        
        btnGoToOrder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 跳转到order模块的页面
                try {
                    Intent intent = new Intent();
                    intent.setClassName(MainActivity.this, "com.test.android.flavor.android.order.OrderActivity");
                    startActivity(intent);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}